package com.jsyh.maidu.presenter;

import android.content.Context;

import com.jsyh.maidu.config.ConfigValue;
import com.jsyh.maidu.http.BaseDelegate;
import com.jsyh.maidu.http.OkHttpClientManager;
import com.jsyh.maidu.model.AttributeModel;
import com.jsyh.maidu.utils.Utils;
import com.jsyh.maidu.views.CartGoodsView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2017/7/20.
 */

public class GetAttribute extends BasePresenter {
    Context context;
    CartGoodsView cartgoodsView;
    public GetAttribute (Context context , CartGoodsView cartgoodsView)
    {
        this.context=context;
        this.cartgoodsView=cartgoodsView;
    }

    public void LaodAttribute(final String goodsid, final String carid)
    {
        Map<String,String> params=new HashMap<>();
        params.put("goods_id",goodsid);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "goods/sel_attr", params, new BaseDelegate.ResultCallback<AttributeModel>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                Utils.showToast(context, "alterCartGoodsNumberError" + e);
            }

            @Override
            public void onResponse(AttributeModel response, Object tag) {
                cartgoodsView.getAttr(response,goodsid,carid);
            }


        });
    }



}
